package reuseplugin.actions.eintrag;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;

import reuseplugin.ClientInterface;

/**
 * @author Julius Ollesch
 * 
 */
public class EintragBearbeitenAction extends Action implements ClientInterface,
		IWorkbenchWindowActionDelegate {
	private TableViewer viewer;

	public EintragBearbeitenAction(TableViewer v) {
		super();
		viewer = v;
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(IWorkbenchWindow window) {
		// TODO Auto-generated method stub

	}

	private void make() {
		IHandlerService handlerService = (IHandlerService) PlatformUI
				.getWorkbench().getService(IHandlerService.class);
		try {
			handlerService.executeCommand(
					"reuseplugin.commands.CallEintragsEditor", null);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(
					"ReusePlugin.commands.CallEintragsEditor not found"
							+ ex.toString());
		}

	}

	@Override
	public void run() {
		make();
	}

	@Override
	public void run(IAction action) {
		make();
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		// TODO Auto-generated method stub

	}
}
